//
//  NoticePublishContentView.swift
//  PropertyCommunity
//
//  Created by benwang on 2021/7/4.
//

import UIKit

class NoticePublishContentView: UIView {
  @IBOutlet weak var areaNoticeButton: UIButton!
  @IBOutlet weak var innerNoticeButton: UIButton!
  @IBOutlet weak var receiveButton: UIButton!
  @IBOutlet weak var receiveTextField: UITextField!
  @IBOutlet weak var textView: PlaceholderTextView!

  override func awakeFromNib() {
    super.awakeFromNib()

    textView.placeholder = "请输入内容"
    tappedNoticeSource(areaNoticeButton)
  }

  /*
   // Only override draw() if you perform custom drawing.
   // An empty implementation adversely affects performance during animation.
   override func draw(_ rect: CGRect) {
   // Drawing code
   }
   */


  @IBAction func tappedNoticeSource(_ sender: UIButton) {
    let buttons = [areaNoticeButton, innerNoticeButton]

    for button in buttons {
      if button == sender {
        button?.backgroundColor = .designKit.primary.withAlphaComponent(0.1)
        button?.layer.borderColor = UIColor.designKit.primary.cgColor
      } else {
        button?.backgroundColor = .designKit.secondaryBackground
        button?.layer.borderColor = UIColor.designKit.secondaryBackground.cgColor
      }
    }

    if sender == areaNoticeButton {
      receiveTextField.text = "某某高档小区"
    } else {
      receiveTextField.text = "已选8人"
    }
  }
}
